package com.mpc.handler;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mpc.manager.StaticizeManager;
import com.mpc.utils.Log;

public class HtmlRequestHandler implements Filter {
    private static final long serialVersionUID = 1705851980213833421L;
    private final String TAG = HtmlRequestHandler.class.getSimpleName();

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        if (!(request instanceof HttpServletRequest)
                || !(response instanceof HttpServletResponse)) {
            return;
        }

        HttpServletRequest httpReq = (HttpServletRequest) request;
        HttpServletResponse httpResp = (HttpServletResponse) response;

        Log.d(TAG, "request uri " + httpReq.getRequestURI());
        StaticizeManager.getInstance().staticizeRequest(httpReq,
                httpResp, false);
    }

    @Override
    public void destroy() {
    }
}
